package org.nanotek.musicbrainz.job.base;

import java.util.Date;
import java.util.List;
import java.util.Set;

import org.springframework.batch.admin.service.JobService;
import org.springframework.batch.core.BatchStatus;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobInstance;
import org.springframework.batch.core.JobParameter;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.JobParametersBuilder;
import org.springframework.batch.core.JobParametersInvalidException;
import org.springframework.batch.core.explore.JobExplorer;
import org.springframework.batch.core.launch.JobExecutionNotRunningException;
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.batch.core.launch.NoSuchJobException;
import org.springframework.batch.core.launch.NoSuchJobExecutionException;
import org.springframework.batch.core.launch.support.SimpleJobOperator;
import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException;
import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException;
import org.springframework.batch.core.repository.JobRestartException;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.validation.Validator;

public class ArtistAliasDataLoad {

	private static ClassPathXmlApplicationContext ctx;

	/**
	 * @param args
	 * @throws JobParametersInvalidException 
	 * @throws JobInstanceAlreadyCompleteException 
	 * @throws JobRestartException 
	 * @throws JobExecutionAlreadyRunningException 
	 * @throws NoSuchJobException 
	 * @throws JobExecutionNotRunningException 
	 * @throws NoSuchJobExecutionException 
	 */
	public static void main(String[] args)  {
		ctx = new ClassPathXmlApplicationContext(new String[] {
		"/spring-batch-jobs/artist_alias/spring-batch-artist-context.xml"});
		Job artistCreditJob = (Job) ctx.getBean("artistAliasIndexJob");
		try { 
			JobLauncher jobLauncher = (JobLauncher) ctx.getBean("jobLauncher");
			jobLauncher.run(artistCreditJob, new JobParametersBuilder().addLong("run.id", System.currentTimeMillis()).toJobParameters());
		}catch (Exception ex) 
		{ 
			ex.printStackTrace();
		}
	}

}
